const express = require('express');
const router = express.Router();

router.get('/', (req, res) => {
    //查询KD整车发运单
    const content = [];
    const {pageIndex, pageSize} = req.query;
    for(let i = 1; i <= 100; i++) content.push({
        id: `${i}`,
        code: `CODE${i}`,
        dealerId: `1errq1-${i}`,
        dealerCode: `s-${i}`,
        dealerName: `s-${i}`,
        status: 1,
        invoicedDate: '2020-03-17T07:21:30.070Z',
        transportType: 1,
        origin: `s-${i}`,
        destination: `s-${i}`,
        expectShipmentDay: 0,
        actualShipmentDay: 0,
        shipmentDate: `s-${i}`,
        expectShipmentDate: '2020-03-17T07:21:30.070Z',
        expectDepartedDate: '2020-03-17T07:21:30.070Z',
        actualDepartedDate: '2020-03-17T07:21:30.070Z',
        expectArrivalDate: '2020-03-17T07:21:30.070Z',
        actualArrivalDate: '2020-03-17T07:21:30.070Z',
        declarePlace: 1,
        declareType: 1,
        receipterName: `s-${i}`,
        receiptTime: `s-${i}`,
        createTime: '2020-03-17T07:21:30.070Z',
        rowVersion: 'string',
        options: ['update', 'abandon', 'signned', 'dateSupplement']
    });
    res.json(
        {
            message: '',
            payload: {
                content,
                pageIndex: parseInt(pageIndex, 10),
                pageSize: parseInt(pageSize, 10),
                totalElements: 40,
            }
        }
    );
});
router.get('/salePackingListPart', (req, res) => {
    //已开票包装箱单查询
    const {pageIndex, pageSize} = req.query;
    res.json(
        {
            message: '',
            payload: {
                content: [{
                    salePackingPartListDetailId: '8851ba03-9286-4ff1-b651-085b49055391',
                    salePackingListId: '48870033-1f25-44ee-962a-13b6082d5545',
                    salePackingListCreateTime: '2020-03-17T07:21:30.070Z',
                    salePackingListCode: 'test004',
                    saleConfirmationId: '7b5addd9-c00c-40ee-bed2-df2d1b877c8e',
                    saleConfirmationrCode: '1003',
                    palletCode: 'NCHERY2020001',
                    batchNumber: 'lytest',
                    partCode: 'HX-00001',
                    partName: '竹笋煎',
                    quantity: 3,
                    price: 20,
                    totalPrice: 60,
                    perNetWeight: 11,
                    netWeight: 33
                },
                {
                    salePackingPartListDetailId: '41f022e1-9dcb-4561-ae19-3681f56fa36f',
                    salePackingListId: '48870033-1f25-44ee-962a-13b6082d5545',
                    salePackingListCreateTime: '2020-03-17T07:21:30.070Z',
                    salePackingListCode: 'test004',
                    saleConfirmationId: '7b5addd9-c00c-40ee-bed2-df2d1b877c8e',
                    saleConfirmationrCode: '1003',
                    palletCode: 'NCHERY2020004',
                    batchNumber: 'localtest',
                    partCode: 'HX-00002',
                    partName: '麻辣烫',
                    quantity: 2,
                    price: 20,
                    totalPrice: 40,
                    perNetWeight: 11,
                    netWeight: 22
                }],
                pageIndex: parseInt(pageIndex, 10),
                pageSize: parseInt(pageSize, 10),
                totalElements: 40,
            }
        }
    );
});
router.post('/', (req, res) => {
    // 新增
    res.json(
        {
            message: '新增成功'
        }
    );
});
router.get('/:id', (req, res) => {
    // 查询KD整车发运单详情
    const content = [];
    for(let i = 1; i <= 3; i++) content.push({
        partId: `${i}`,
        partCode: `CODE${i}`,
        partName: 'string',
        unit: 'ET',
        price: 10,
        orderQuantity: 10,
        remark: 'string'
    });
    res.json(
        {
            message: 'string',
            payload: {
                details: {
                    id: 'string',
                    code: 'string',
                    brandId: 'string',
                    brandCode: 'string',
                    brandName: 'string',
                    dealerId: 'string',
                    dealerCode: 'string',
                    dealerName: 'string',
                    ciCode: 'string',
                    invoicedDate: '2020-03-17T07:26:02.665Z',
                    transportType: 1,
                    batchNumber: 'batchNumber',
                    origin: 'string',
                    destination: 'string',
                    actualShipmentDate: '2020-03-17T07:26:02.665Z',
                    expectDepartedDate: '2020-03-17T07:26:02.665Z',
                    expectShipmentDate: '2020-03-17T07:26:02.665Z',
                    shipmentDate: 'string',
                    expectShipmentDay: 10,
                    actualShipmentDay: 10,
                    actualDepartedDate: '2020-03-17T07:26:02.665Z',
                    expectArrivalDate: '2020-03-17T07:26:02.665Z',
                    actualArrivalDate: '2020-03-17T07:26:02.665Z',
                    shipmentNumber: 'string',
                    shippingCompanyAirline: 'string',
                    declarePlace: 1,
                    declareType: 1,
                    remark: 'string',
                    signnedRemark: 'string',
                    creatorName: 'string',
                    createTime: '2020-03-17T07:26:02.665Z',
                    modifierName: 'string',
                    modifyTime: '2020-03-17T07:26:02.665Z',
                    confirmerName: 'string',
                    confirmTime: '2020-03-17T07:26:02.665Z',
                    receipterName: 'string',
                    receiptTime: '2020-03-17T07:26:02.665Z',
                    rowVersion: 'string',
                    details: [
                        {
                            salePackingPartListDetailId: '41f022e1-9dcb-4561-ae19-3681f56fa36f',
                            salePackingListId: '48870033-1f25-44ee-962a-13b6082d5545',
                            salePackingListCreateTime: '2020-03-17T07:21:30.070Z',
                            salePackingListCode: 'test004',
                            saleConfirmationId: '7b5addd9-c00c-40ee-bed2-df2d1b877c8e',
                            saleConfirmationrCode: '1003',
                            palletCode: 'NCHERY2020001',
                            batchNumber: 'lytest',
                            partCode: 'HX-00002',
                            partName: '麻辣烫',
                            quantity: 2,
                            price: 20,
                            totalPrice: 40,
                            perNetWeight: 11,
                            netWeight: 22
                        }
                    ],
                    attachments: [
                        {
                            fileId: '001',
                            fileName: 'fileName001'
                        }
                    ],
                    options: ['update', 'abandon', 'signned', 'dateSupplement']
                }
            }
        }
    );
});
router.put('/:id', (req, res) => {
    //修改
    res.json(
        {
            message: '修改成功'
        }
    );
});
router.put('/:id/abandon', (req, res) => {
    //签收
    res.json(
        {
            message: '成功签收'
        }
    );
});
router.put('/:id/signned', (req, res) => {
    //作废
    res.json(
        {
            message: '成功作废'
        }
    );
});
router.put('/:id/datesupplement', (req, res) => {
    //日期补录
    res.json(
        {
            message: '成功日期补录'
        }
    );
});
router.post('/import', (req, res) => {
    //序列号
    res.json({
        message: '导入成功'
    });
});
module.exports = router;
